﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.Web;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.Model.Enum;
namespace HZ.DrugTrade.Web.Enterprise.RelationQuery
{
    public partial class RelationQueryUnpack1 : BasePage
    {
        public RelationQueryUnpack1()
        {
            this.ModuleNo = Module.分配送管理.ToString();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BangdinGvRelaion();

            }
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            BangdinGvRelaion();
        }
        /// <summary>
        /// 绑定事件
        /// </summary>
        private void BangdinGvRelaion()
        {
            HZ.DrugTrade.Model.Query.ProcureCatalog procureCatalog = new HZ.DrugTrade.Model.Query.ProcureCatalog();
            procureCatalog.CompanyID_TB = CurrentAccount.GetUser().Org.OrgID;
            procureCatalog.Material = txtMaterial.Text.Trim();
            procureCatalog.Outlookc = txtOutlookc.Text.Trim();
            procureCatalog.Unit = txtUnit.Text.Trim();
            procureCatalog.PinyinCode = this.txtPinyinCode.Text.Trim().ToUpper();
            procureCatalog.GoodsName = txtGoodsName.Text.Trim();
            procureCatalog.SortFields = " productname desc ";
            GvRelaion.AutoGenerateColumns = false;
            int totalrecord = 0;
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            IBLL_ProcurementBasic iDistribution = Factory.BLL_ProcurementBasic();
            this.GvRelaion.DataSource = iDistribution.GetProcureCatalogByWhere(procureCatalog, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalrecord);
            GvRelaion.DataBind();
            AspNetPager1.RecordCount = totalrecord;
        }
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            BangdinGvRelaion();
        }

        /// <summary>
        /// 将给定的url加上script 实现页面跳转
        /// 针对button 的 onclintclick 新窗口打开
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        protected string OpenURLScript(string str)
        {
            int index = str.IndexOf("?");
            //给url加returnUrl,值为当前页面的Url
            if (index != -1)
            {
                str += "&" + Constants.QUERYSTRING_RETURN_URL + "=" + Page.Request.RawUrl;
            }
            else
            {
                str += "?" + Constants.QUERYSTRING_RETURN_URL + "=" + Page.Request.RawUrl;
            }
            string strScript = "if(!this.disabled){window.open('" + str + "');} return false;";
            return strScript;
        }
    }
}
